// src/api/productApi.js
import http from '../util/request.js';

export default {
    // 获取产品列表（支持模糊查询）
    list: (params = {}) => http({
        url: '/api/product',
        method: 'get',
        params,
    }),

    // 分页获取产品列表
    page: (page, params = {}) => http({
        url: '/api/product/page',
        method: 'get',
        params: { ...params, ...page },
    }),

    // 添加产品
    add: (obj) => http({
        url: '/api/product',
        method: 'post',
        data: obj,
        headers: { 'Content-Type': 'application/json' },
    }),

    // 编辑产品
    edit: (obj) => http({
        url: `/api/product/${obj.id}`,
        method: 'put',
        data: obj,
        headers: { 'Content-Type': 'application/json' },
    }),

    // 删除产品
    del: (id) => http({
        url: `/api/product/${id}`,
        method: 'delete',
    }),

    // 获取单个产品
    one: (id) => http({
        url: `/api/product/${id}`,
        method: 'get',
    }),
};
